package com.ophiux.cs.domain.chat.model.entity;

import com.ophiux.compoments.TableEnum;
import com.ophiux.cs.domain.chat.model.valueobj.CSUserValue;
import com.ophiux.cs.domain.core.Entity;
import com.ophiux.cs.domain.core.TbableUniqueIDFactory;
import com.ophiux.utils.common.DateUtil;

/**
 * 聊天消息表
 * @author chenh
 *
 */
public class CSChatMessageSend extends Entity{

	public final static String MSG_TYPE_TW = "1";
	
	public final static String STATE_SUCCESS = "1";
	public final static String STATE_FAIL = "0";
	
	public final static String ISREAD = "1";
	public final static String ISUNREAD = "0";
	
	public final static String IS_REMOVE_TRUE = "1";
	public final static String IS_REMOVE_FALSE = "0";
	
	public final static String TYPE_SEND = "1";
	public final static String TYPE_RECEIVE = "2";
	
	private String SESSION_ID;	//会话标识
	
	private String SEND_ID;	//发送/接收唯一标识	唯一标识
	
	private String MSG_ID;	//消息信息ID
	
	private String STATE;	//	状态	VARCHAR2(5)	可空	1：成功  0：失败

	private String TIME;	//	发送/接收时间	VARCHAR2(32)	不可空
	
	private String READ_TIME;	//	读取时间	VARCHAR2(32)	可空
	
	private String DAY;	//	发送/接收星期	VARCHAR2(32)	不可空	星期一、星期二…

	private String IS_READ;		//1：已读  0：未读
	
	private String IS_REMOVE;	//是否删除，1：删除   0：未删除
	
	private String REMOVE_TIME;	//删除时间
	
	private String TYPE;	//发送/接收   1：发送    2：接收
	
	//创建时间
	private String CREATE_TIME;
	
	private String DIALOG_ID;	//对话标识，业务标记
	
	private CSChatMessageInfo message;	//消息内容

	public CSChatMessageSend() {
		super();
	}

	public CSChatMessageSend(String sESSION_ID,String tYPE, String dIALOG_ID,
			CSChatMessageInfo message) {
		super();
		this.setCREATE_TIME(DateUtil.getCurDateStr());
		this.setDIALOG_ID(dIALOG_ID);
		
		this.setIS_REMOVE(IS_REMOVE_FALSE);
		this.setMessage(message);
		this.setMSG_ID(message.getMSG_ID());
		
		String sendID = TbableUniqueIDFactory.getInstance()
				.createUniqueID(TableEnum.TABLE_SQE_CS_CHAT_MESSAGE_SEND.toString());
		this.setSEND_ID(sendID);
		this.setSESSION_ID(sESSION_ID);
		
		this.setTYPE(tYPE);
		
		this.setSTATE(STATE_SUCCESS);
		this.setTIME(DateUtil.getCurDateStr());
		this.setDAY(DateUtil.getCurDay());
		
	}

	public String getCREATE_TIME() {
		return CREATE_TIME;
	}

	public String getTYPE() {
		return TYPE;
	}

	public void setTYPE(String tYPE) {
		TYPE = tYPE;
	}

	public String getDIALOG_ID() {
		return DIALOG_ID;
	}

	public void setDIALOG_ID(String dIALOG_ID) {
		DIALOG_ID = dIALOG_ID;
	}

	public void setCREATE_TIME(String cREATE_TIME) {
		CREATE_TIME = cREATE_TIME;
	}

	public String getMSG_ID() {
		return MSG_ID;
	}

	public void setMSG_ID(String mSG_ID) {
		MSG_ID = mSG_ID;
	}

	public String getSEND_ID() {
		return SEND_ID;
	}

	public void setSEND_ID(String sEND_ID) {
		SEND_ID = sEND_ID;
	}


	public String getREAD_TIME() {
		return READ_TIME;
	}

	public void setREAD_TIME(String rEAD_TIME) {
		READ_TIME = rEAD_TIME;
	}
	
	public String getSTATE() {
		return STATE;
	}

	public void setSTATE(String sTATE) {
		STATE = sTATE;
	}

	public String getTIME() {
		return TIME;
	}

	public void setTIME(String tIME) {
		TIME = tIME;
	}

	public String getDAY() {
		return DAY;
	}

	public void setDAY(String dAY) {
		DAY = dAY;
	}

	public String getIS_READ() {
		return IS_READ;
	}

	public void setIS_READ(String iS_READ) {
		IS_READ = iS_READ;
	}

	public String getSESSION_ID() {
		return SESSION_ID;
	}

	public void setSESSION_ID(String sESSION_ID) {
		SESSION_ID = sESSION_ID;
	}

	public String getIS_REMOVE() {
		return IS_REMOVE;
	}

	public void setIS_REMOVE(String iS_REMOVE) {
		IS_REMOVE = iS_REMOVE;
	}

	public String getREMOVE_TIME() {
		return REMOVE_TIME;
	}

	public void setREMOVE_TIME(String rEMOVE_TIME) {
		REMOVE_TIME = rEMOVE_TIME;
	}

	
	/**
	 * 已读标记
	 */
	public void read() {
		
		this.setREAD_TIME(DateUtil.getCurDay());
		this.setIS_READ(ISREAD);
		
	}
	
	/**
	 * 删除消息
	 */
	public void remove() {
		
		this.setIS_REMOVE(IS_REMOVE_TRUE);
		this.setREMOVE_TIME(DateUtil.getCurDateStr());
		
	}
	
	public CSChatMessageInfo getMessage() {
		return message;
	}

	public void setMessage(CSChatMessageInfo message) {
		this.message = message;
	}

	/**
	 * 撤销
	 */
	public void undo() {
		this.message.undo();
	}
	
}
